package com.easyfile.easyfilemaster.config;

import com.easyfile.easyfilemaster.service.MyMinioClient;
import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置minio
 * @author chenpeman
 * @date 2022年05月06日 15:03
 */
@Configuration
public class MinioConfig {
    @Value("${minio.endpoint}")
    private String endpoint;
    @Value("${minio.accessKey}")
    private String accessKey;
    @Value("${minio.secretKey}")
    private String secretKey;

    /**
     * 注入自定义的minio 客户端
     *
     * @return minio client
     */
    @Bean
    public MyMinioClient minioClient(){
        return new MyMinioClient(MinioClient.builder()
                .endpoint(endpoint)
                .credentials(accessKey, secretKey)
                .build());
    }

}
